package org.tmad.ocms.web;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.sql.Connection;
import java.sql.Statement;
import java.sql.ResultSet;
import java.io.*;


/**
 * Servlet implementation class CaseDetailsServlet
 */
public class CaseDetailsServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public CaseDetailsServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	
	
	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	try{
	response.setContentType("text/html");
		Connection con =org.tmad.ocms.dao.ConnectionManager.getDbConnection();
		Statement stmt =con.createStatement();
		PrintWriter pw=response.getWriter();
		ResultSet rs =stmt.executeQuery("select * from casereg ");
		String casetype=rs.getString(9);
		String helpcategory=rs.getString(8);
		String summary=rs.getString(6);	
		String description=rs.getString(7);
		String needyname=rs.getString(2);
		String address=rs.getString(3);
		String mobile=rs.getString(14);
		
		pw.println("<html><body><table border=1 cellpadding=3 cellspacing=0>");
		pw.println("<h2>CaseRegistration details</h2>");
		pw.println("<tr>");
		pw.println("<th align=right width=100>caseType</th>");
		pw.println("<th align=right width=100>helptype</th>");
		pw.println("<th align=right width=100>summary</th>");
		pw.println("<th align=right width=100>description</th>");
		pw.println("<th align=right width=100>needyname</th>");
		pw.println("<th align=right width=100>address</th>");
		pw.println("<th align=right width=100>mobile</th>");
		pw.println("<th align=right width=100>emailid</th>");
		pw.println("</tr>");
		while(rs.next())
		{
		pw.println("<h2>CaseRegistration details</h2>");
		pw.println("<tr>");
		pw.println("<td>"+casetype+"</td>");
		pw.println("<td>"+helpcategory+"</td>");
		pw.println("<td>"+summary+"</td>");
		pw.println("<td>"+description+"</td>");
		pw.println("<td>"+needyname+"</td>");
		pw.println("<td>"+address+"</td>");
		pw.println("<td>"+mobile+"</td>");
		}
		pw.println("</table></body></html>");
	
	}catch(Exception e)

	{e.printStackTrace();}
		
	}}
